﻿
namespace Oddo.Concept.Crm.Common.Communication.Requests.Base
{
    using System.ComponentModel;
    using Newtonsoft.Json;
    using Oddo.Concept.Crm.Common.Communication.Interfaces;
    using Oddo.Concept.Crm.Common.Interfaces;
    using Oddo.Concept.Crm.Common.Models;

    [JsonObject(MemberSerialization.OptOut)]
    public abstract class RequestBase : IRequest, INotifyPropertyChangedEx
    {
        [field:JsonIgnore]
        public virtual event PropertyChangedEventHandler PropertyChanged;
        [JsonIgnore]
        public virtual bool ShouldNotifyPropertyChanged { get { return true; } set{} }
        public virtual void NotifyPropertyChanged(string propertyname)
        {
            var handler = PropertyChanged;
            if(handler!=null)
                handler(this, new PropertyChangedEventArgs(propertyname));
        }
    }

    [JsonObject(MemberSerialization.OptOut)]
    public abstract class RequestBase<T> : RequestBase, IRequest<T> 
        where T : IBusinessModel
    {
    }
}